﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Protocal.App.Common;
using Protocal.App.Common.Models;

namespace 多协议通信平台.Views.Login.Components
{
    /// <summary>
    /// WinXinLoginView.xaml 的交互逻辑
    /// </summary>
    public partial class WinXinLoginView : Page
    {
        public WinXinLoginView()
        {
            InitializeComponent();
        }

        private void NavigateToUrl(object sender, MouseButtonEventArgs e)
        {
            var textBlock = sender as TextBlock;
            if (textBlock != null)
            {
                string url = textBlock.Tag.ToString();

                Debug.WriteLine($"begin: {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
                TaskQueueHelper.AddModel(new TaskModel()
                {
                    DelayTime = 2000,
                    Action = () =>
                    {
                        Process.Start(new ProcessStartInfo(url)
                        {
                            UseShellExecute = true
                        });
                    }
                });

                // 获取Page所在的宿主窗口
                var hostWindow = Window.GetWindow(this);

                // 关闭宿主窗口（如果是模态窗口）
                hostWindow?.Close();
            }
        }

        private void Back_Register_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.GoBack();
        }
    }
}
